package com.project.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.bean.StockBean;
import com.project.service.IStockService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("stock")
public class StockController {
    @Autowired
    private IStockService stockService;

    @RequestMapping("findById")//通过商品编号，查找商品
    public StockBean findById(String id) {
        return stockService.findById(id);
    }
    @RequiresPermissions("outbound")
    @RequestMapping("findOutByItem")//添加出库商品的---动态分页查询所有有销售价的商品
    public IPage<StockBean> findOutByItem(Integer pageNO, String name, String kind) {
        return stockService.findOutByItem(pageNO, name, kind);
    }
    @RequiresPermissions("stock")
    @RequestMapping("findByItem")//库存一览----- 根据输入的条件动态的查询库存商品信息
    public IPage<StockBean> findByItem(Integer pageNO, String name, String outPrice,
                                       String kind, Integer startNum, Integer endNum) {
        return stockService.findByItem(pageNO, name, outPrice, kind, startNum, endNum);
    }
    @RequiresPermissions("stock")
    @RequestMapping("updateInfo")//通过库存商品id编号修改销售价格
    public String updateInfo(String id, Integer newOutPrice) {
        stockService.updateInfo(id, newOutPrice);
        return "ok";
    }
}
